#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
int main(){
    // Open camera
    cv::VideoCapture input_stream(0);
        // check
    if (!input_stream.isOpened()){
        std::cerr<<"Failed to open camera!\n";
        return EXIT_FAILURE;
    }
    // Create a window
    const std::string window_title = "Inverted Color Video";
    cv::namedWindow(window_title, cv::WINDOW_NORMAL);
    cv::Mat frame,inverted_frame;
    
    while(true){
        // Capture a frame
        input_stream>>frame;
        if(frame.empty()){
            break;
        }
        // Invert color
        cv::bitwise_not(frame,inverted_frame);
        // Display invertcolor video
        cv::imshow(window_title,inverted_frame);
        // Press the Esc key to exit
        if(cv::waitKey(15)==27){
            break;
        }
    }
    // Release resources
    input_stream.release();
    cv::destroyAllWindows();
    return 0;
}